const get_client_ip = (req) => {
  let ipStr = req._remoteAddress || req.headers['x-forwarded-for'] ||
    req.ip ||
    req.connection._remoteAddress ||
    req.socket._remoteAddress ||
    req.connection.socket._remoteAddress || '';
  let ipReg = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/;
  if (ipStr.split(',').length > 0) {
    ipStr = ipStr.split(',')[0]
  }
  let ip = ipReg.exec(ipStr);
  return ip[0];
}
const getNowTime = () => {
  let datetime = new Date();
  return datetime.toLocaleDateString() + " " + datetime.toTimeString().slice(0, 8);
}


module.exports = {
  get_client_ip,
  getNowTime
};